/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) DDK 1.10.00.23 07-02-03 (ddk-b12)" */
/*
 *  ======== uartmd.h ========
 */

#ifndef UARTMD_
#define UARTMD_

#include <iom.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Version number definition */
#define UARTMD_VERSION_1 0xAB01

/* ---- control codes and parameters ---- */

#define UARTMD_REGISTER_NOTIFY  1
#define UARTMD_SETBREAK         2
#define UARTMD_GETMODEMSTATUS   3
#define UARTMD_SETRTS           4
#define UARTMD_SETDTR           5

#define UARTMD_LSR_OEMASK       0x02
#define UARTMD_LSR_PEMASK       0x04
#define UARTMD_LSR_FEMASK       0x08
#define UARTMD_LSR_BRKMASK      0x10
#define UARTMD_LSR_THEMASK      0x20

#define UARTMD_MSR_CTSCHGMASK   0x01
#define UARTMD_MSR_DSRCHGMASK   0x02
#define UARTMD_MSR_CTSMASK      0x10
#define UARTMD_MSR_DSRMASK      0x20

typedef void (*UARTMD_TnotifyHandler)(Uns evtStatus, Uns info);

typedef struct {
    UARTMD_TnotifyHandler   notifyFunc;
    Uns                     evtMask;
} UARTMD_NotifyStruct;

typedef enum {
    UARTMD_EVT_CTSCHANGE       = 0x0001,        
    UARTMD_EVT_DSRCHANGE       = 0x0002,
    UARTMD_EVT_BREAK           = 0x0004,
    UARTMD_EVT_PERR            = 0x0008,
    UARTMD_EVT_FERR            = 0x0010,
    UARTMD_EVT_OERR            = 0x0020,
    UARTMD_EVT_BERR            = 0x0040
} UARTMD_EventMask;

#define UARTMD_EVT_ALL (UARTMD_EVT_CTSCHANGE|UARTMD_EVT_DSRCHANGE|\
                        UARTMD_EVT_BREAK|UARTMD_EVT_PERR|UARTMD_EVT_FERR\
                        UARTMD_EVT_OERR|UARTMD_EVT_BERR)

/* Driver function table to be used by applications. */
extern IOM_Fxns UARTMD_FXNS;

/*
 * Device Parameters.
 *
 * 'packedChars' is only used for 54x and 55x.  If 'packedChars' is
 * TRUE, then the UARTMD driver will output the low and then high part
 * of the 16-bit word.  If 'packedChars' is FALSE, the UARTMD driver
 * will output only the low eight bits of each word.  This parameter
 * is needed for 54x and 55x when using the UART to transfer raw data.
 * 'packedChars' should be set to 'FALSE' when using UARTMD for ASCII
 * characters.
 *
 * 'uarthwParams' is an opaque pointer to an implementation-specific 
 * UARTHW_Params structure.  If this is NULL, the UARTHW_attach()
 * function will use a default set of parameters to initialize the UART.
 */
typedef struct UARTMD_DevParams {
    Int         versionId;      /* Version number to be set by the app */
    Bool        packedChars;    /* only used for c55xx and 54xx */
    Ptr         uarthwParams;
} UARTMD_DevParams;

#define UARTMD_DEVPARAMS_DEFAULT {      \
    UARTMD_VERSION_1,                   \
    FALSE,      /* packedChars */       \
    NULL        /* uarthwParams */      \
}

/* Mini-driver init function -- initializes drivers variables, if any */
extern  Void UARTMD_init( Void );

#ifdef __cplusplus
}
#endif /* extern "C" */

#endif /* UARTMD_ */

